home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / ARGONET / PD / PROGRAMMING / DESKLIBC / SOURCES.ZIP / DeskLib / !DLSources / Libraries / Event / c / MRelease < prev    next >
Text File  |  1995-07-08  |  2KB  |  63 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for 
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #                                      
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    Event.MRelease.c
  12.     Author:  Copyright © 1992 Jason Williams
  13.     Version: 1.00 (16 Mar 1992)
  14.     Purpose: Extension to Event.c to allow routing of specific message types
  15.              to different windows' message handlers.
  16. */
  17.  
  18. #include "EMsgDefs.h"
  19.  
  20.  
  21.  
  22. extern int EventMsg_Release(message_action messagetype, window_handle window,
  23.                             event_handler handler)
  24. {
  25.   eventmsg_claimrecord *ptr, *nextmess;
  26.   eventmsg_windowrecord *wptr, *next;
  27.   int result = 0;
  28.  
  29.   ptr = (eventmsg_claimrecord *) eventmsg__claimanchor.next;
  30.  
  31.   while (ptr != NULL)                           /* Search all message claims */
  32.   {
  33.     if (ptr->messagetype == messagetype)
  34.     {
  35.       wptr = (eventmsg_windowrecord *) ptr->windowlist.next;
  36.       while (wptr != NULL)                      /* Search all window claims  */
  37.       {
  38.         next = (eventmsg_windowrecord *) wptr->header.next;
  39.         if (wptr->window == window && wptr->handler == handler)
  40.         {                            /* Found claim for window+handler combo */
  41.           LinkList_Unlink(&(ptr->windowlist), &(wptr->header));
  42.           free(wptr);
  43.           result += 1;                     /* Count of window claims removed */
  44.         }
  45.         wptr = next;
  46.       }
  47.  
  48.       nextmess = (eventmsg_claimrecord *) ptr->header.next;
  49.       if (ptr->windowlist.next == NULL)               /* m-list is now empty */
  50.       {
  51.         LinkList_Unlink(&eventmsg__claimanchor, &(ptr->header));
  52.                                                       /* remove message type */
  53.         free(ptr);                                    /* free memory up      */
  54.       }
  55.       ptr = nextmess;
  56.     }
  57.     else
  58.       ptr = (eventmsg_claimrecord *) ptr->header.next;
  59.   }
  60.  
  61.   return(result);
  62. }
  63.